<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
		<title>生命体征检测云平台</title>
		<link rel="shortcut icon" href="static/logo.ico" />
		<link rel="stylesheet" href="static/css/index.css" />
		<link rel="stylesheet" href="static/layui/css/layui.css" />
		<script type="text/javascript" src="static/js/jquery.min.js"></script>
		<script src="static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="static/js/vue.js"></script>
		<script type="text/javascript" src="static/js/axios.min.js"></script>
		<style>
			html,
			body,
			#container {
				height: 100%;
				width: 100%;
			}

			.container {
				height: auto;
				width: 100%;
			}

			.container 2 {
				height: auto;
				width: 100%;
			}

			.collision-btn.disable {
				background-image: none;
				color: lightgrey;
				border-color: lightgrey;
				cursor: not-allowed;
			}

			.collision-btn.disable:hover {
				background-color: #fff;
				border-color: lightgrey;
			}

			.input-card .btn {
				margin-right: .8rem;
			}

			.amap-marker {
				opacity: 0.01;
			}

			.nav-right {
				top: 1.5rem !important;
			}

			.info {
				z-index: 999 !important;
			}

			.layui-form-label {
				width: 110px;
				font-size: 14px !important;
			}

			::-webkit-input-placeholder {
				/*Webkit browsers*/
				color: #999;
				font-size: 13px;
			}

			:-moz-placeholder {
				/*Mozilla Firefox 4 to 8*/
				color: #999;
				font-size: 13px;
			}

			::moz-placeholder {
				/*Mozilla Firefox 19+*/
				color: #999;
				font-size: 13px;
			}

			:-ms-input-placeholder {
				/*Internet Explorer 10+*/
				color: #999;
				font-size: 13px;
			}

			.layui-form-pane .layui-input {
				height: 38px !important;
			}

			.layui-form-onswitch {
				border-color: #063683;
				background-color: #063683;
			}

			.layui-form-switch {
				width: 50px;
				height: 24px;
			}

			.layui-form-label {
				width: 150px;
			}

			.layui-layer-tips .layui-layer-content {
				background-color: #063683;
			}

			.layui-layer-tips i.layui-layer-TipsL,
			.layui-layer-tips i.layui-layer-TipsR {
				border-bottom-color: #063683;
			}

			.layui-upload-list img {
				width: 100px;
				height: 100px;
				padding: 0.625rem;
			}
		</style>
		<script>
			layui.use(['form', 'layedit', 'laydate', 'dropdown', 'upload', 'element'], function() {
				var rloginName = localStorage.loginName;
				var equName = localStorage.equName;
				var data = new FormData();
				data.append('equName', equName.toString());
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate,
					dropdown = layui.dropdown,
					upload = layui.upload,
					element = layui.element;
				dropdown.on('click(docDemoMenu1)', function(options) {
					var othis = $(this); //当前菜单列表的 DOM 对象
					console.log(options.url)
				});
				laydate.render({
					elem: '#date1'
				});
				//多图片上传
				//      upload.render({
				//          elem: '#img_upload_btn'         //绑定点击按钮
				//          ,url: url + "/user/tousu/testFiles"      //访问后台路径
				//          ,multiple: true                 //确认上传多张图片
				//          ,accept: 'file' //图片格式
				// ,field: "fileList"
				//          ,number: 6                      //最大上传图片数量
				//          ,auto:false                     //取消自动上传
				//          ,method: 'post'                 //请求上传的 http 类型
				//          ,bindAction:'#hideUpload'       //绑定真正的上传按钮
				//          ,data:{                         //访问后台提交的数据
				//              userPhone:()=>{
				//                  return localStorage.loginName;//官方文档说明：实现动态传值
				//              },
				//              propose:()=>{
				//                    return $('#contents').val();//官方文档说明：实现动态传值
				//              }  
				//          }
				//          ,choose: function(obj){
				//              obj.preview(function(index, file, result){
				//                  $('#img_upload').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">');
				//              });
				//          }
				//          ,done: function(res){
				//              //上传完毕
				// 	console.log(res)
				// 	if (res.code == 0) {
				// 		layer.msg(res.message, {
				// 			time: 2000,
				// 			end: function() {
				// 				// location.href = 'home.html'
				// 			}
				// 		})
				// 	} else {
				// 		layer.msg(res.message);
				// 	}
				//          }
				//      });
				var files;
				upload.render({
					elem: '#img_upload_btn',
					before(res) {
						console.log(res);
					},
					multiple: true,
					number: 6,
					size: 5120 //图片上传的大小最大为5M
						,
					exts: "jpg|png|jpeg",
					auto: false, //选定文件后不自动上传
					allDone: function(obj) { //当文件全部被提交后，才触发
						console.log(obj.total); //得到总文件数
						console.log(obj.successful); //请求成功的文件数
						console.log(obj.aborted); //请求失败的文件数
						console.log(obj);
					},
					choose: (obj) => {
						obj.preview(function(index, file, result) {
							$('#img_upload').append('<img src="' + result + '" alt="' + file.name +
								'" class="layui-upload-img">');
						});
						files = obj.pushFile();
					}
				})

				form.on('submit(submitForm)', function(data) {
					console.log(files);
					var formData = new FormData();
					for (let i in files) {
						formData.append("fileList", files[i]);
					}
					formData.append("userPhone", localStorage.loginName);
					formData.append("propose", $('#contents').val());
					$.ajax({
						type: 'POST',
						url: url + "/user/tousu/testFiles",
						data: formData,
						processData: false,
						contentType: false,
						async: false,
						dataType: "json",
						success: function(result) {
							console.log(result);
							if (result.code == 0) {
								layer.msg(result.message, {
									time: 2000,
									end: function() {
										location.href = 'home.html'
									}
								})
							} else {
								layer.msg(result.message);
							}
						}
					});


				});
			});
		</script>
	</head>
	<body>
		<div id="app">

			<div style="margin-top: 70px;background-color: #e5e5e5;"></div>
			<div class="layui-panel" style="float: left; width: 10% !important;" id="pnav">

			</div>
			<div class="container" style="width: 90% !important; float: right;padding-left: 30px;">
				<div class="layui-fluid">
					<fieldset class="layui-elem-field layui-field-title">
						<legend>投诉建议</legend>
					</fieldset>
					<div class="layui-row">
						<div class="layui-col-sm12"
							style="padding: 20px;box-shadow: 0 2px 4px 0 rgba(0,0,0,.1);background: #fff;">
							<div class="grid-demo grid-demo-bg1">
								<div class="layui-row">
									<div class="layui-col-md12">
										<div class="layui-form-item layui-form-text">
											<label class="layui-form-label">意见说明</label>
											<div class="layui-input-block">
												<textarea placeholder="请输入意见内容" class="layui-textarea"
													style="width: 500px;" id="contents"></textarea>
											</div>
										</div>
										<div class="layui-form-item layui-form-text">

											<div class="layui-upload">
												<button type="button" class="layui-btn layui-btn-xs" id="img_upload_btn"
													style="margin-left: 6.25rem;">多图片上传</button>
												<blockquote class="layui-elem-quote layui-quote-nm"
													style="margin-top: 10px;margin-left: 149px; width: 500px;">
													预览：
													<div class="layui-upload-list" id="img_upload"></div>
												</blockquote>
											</div>
										</div>
										<div class="layui-form-item">
											<div class="layui-input-block">
												<button type="submit" class="layui-btn" lay-submit=""
													lay-filter="submitForm" id="hideUpload">立即提交</button>
												<!-- <button class="layui-btn layui-btn-primary">重置</button> -->
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="info">
				<div class="nav-left">
					<a class="login"></a>
					<a class="hometext" href="index.html" v-if="uInfoData.loginType !=1">首页</a>
					<a class="hometext" href="home.html" v-if="uInfoData.loginType == 1">首页</a>
				</div>
				<div class="nav-right">
					<ul>
						<li><a href="monitoring.html" v-if="uInfoData.loginType !=1">监测</a></li>
						<li><a href="historical_data.html" v-if="uInfoData.loginType !=1">历史数据</a></li>
						<li><a href="historical_info.html" v-if="uInfoData.loginType == 1">历史数据</a></li>
						<li><a href="call_p.html">离床报警</a></li>
						<li><a href="#">康养中心</a></li>
						<li><a href="#">中医问诊</a></li>
					</ul>
				</div>
				<div class="userinfo" id="userinfo">
					<img src="static/image/user.png" />
					<!-- <div class="red-dot"></div> -->
					<ul class="user_dropdown">
						<li class="dropdown_item user_ctrl">
							<div class="nickname">{{uInfoData.userName}}</div>
							<div class="sign_out">退出</div>
						</li>
						<li class="dropdown_item msg_item">
							<a href="user.html" target="_blank">
								<span>个人中心</span>
							</a>
						</li>
						<li class="dropdown_item msg_item">
							<a href="my_message.html" target="_blank">
								<span>我的消息</span>
								<span class="msg_unread unread_count show">5</span>
							</a>
						</li>
						<li class="dropdown_item">
							<a href="equipment.html">
								<span>设备</span>
							</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="static/js/config.js"></script>
		<script>
			$(function() {
				$("#pnav").load("public_navigation.html");
				$(".sign_out").click(function() {
					localStorage.clear();
					window.location = 'login.html'
				});
			});
			var vm = new Vue({
				el: '#app', //设置当前vue对象可以操作数据的范围,注意不要把vue对象绑定到body中，因为这样，vue需要控制整个页面的内容，效率太低了
				data: {
					uInfoData: [],
					equipmentData: [],

				},
				ready: function() {
					// this.getdata();
				},
				created: function() {
					this.getdata();

				},
				methods: {
					getdata: function() {
						var rloginName = localStorage.loginName;
						console.log(rloginName);
						if (rloginName == '' || rloginName == 'null' || rloginName == undefined) {
							layer.msg('登录过期或者无权访问！', {
								time: 1000,
								end: function() {
									location.href = 'login.html'
								}
							})
						} else {
							axios({
									method: 'GET',
									url: url + "/user/userInfo/lquserOwnInfo?phoneNum=" + rloginName,
									data: {}
								})
								.then(function(response) {
									console.log(response)
									vm.uInfoData = response.data;
								})
							axios({
									method: 'GET',
									url: url + "/user/equipment/infoList?userId=" + rloginName,
									data: {}
								})
								.then(function(response) {
									console.log(response)
									vm.equipmentData = response.data;
								})
						}
					},

					insertSq: function() {
						var einfo = $('#einfo').val();
						var sbxx = $('#sbdata').val();
						var dwdz = $('#dwdata').val();
						var jcsj = $('#jcdata').val();
						var bjsj = $('#bjdata').val();
						var bslist = $('#jcbdata').val();
						var rloginName = localStorage.loginName;
						console.log(einfo);
						console.log(sbxx);
						console.log(dwdz);
						console.log(jcsj);
						console.log(bjsj);
						console.log(bslist);
						console.log(rloginName);
						let data = {
							'equName': einfo,
							'isEquname': sbxx,
							'isAddress': dwdz,
							'isJcData': jcsj,
							'isWarningData': bjsj,
							'isDisease': bslist,
						};
						if (einfo == "undefined" || einfo == null || einfo == "") {
							layer.msg('请选择设备，设备选项不能为空！')
						} else {
							axios({
									method: 'POST',
									url: url + "/empowerManage/insert",
									data: data //JSON.parse(JSON.stringify(sqInfo))
								})
								.then(function(response) {
									var data = response.data;
									var message = response.data.message;
									if (data.code == 0) {
										layer.msg(message, {
											time: 2000,
											end: function() {
												location.href = 'authorization.html'
											}
										})
									} else {
										layer.msg(message);
									}
								})
						}
					},
					updateSq: function() {
						var einfo = $('#einfo').val();
						var sbxx = $('#sbdata').val();
						var dwdz = $('#dwdata').val();
						var jcsj = $('#jcdata').val();
						var bjsj = $('#bjdata').val();
						var bslist = $('#jcbdata').val();
						var rloginName = localStorage.loginName;
						console.log(einfo);
						console.log(sbxx);
						console.log(dwdz);
						console.log(jcsj);
						console.log(bjsj);
						console.log(bslist);
						console.log(rloginName);
						var data = new FormData();
						data.append('equName', einfo);
						data.append('isEquname', sbxx);
						data.append('isAddress', dwdz);
						data.append('isJcData', jcsj);
						data.append('isWarningData', bjsj);
						data.append('isDisease', bslist);
						if (einfo == "undefined" || einfo == null || einfo == "") {
							layer.msg('请选择设备，设备选项不能为空！')
						} else {
							axios({
									method: 'POST',
									url: url + "/empowerManage/update",
									data: data //JSON.parse(JSON.stringify(sqInfo))
								})
								.then(function(response) {
									var data = response.data;
									var message = response.data.message;
									if (data.code == 0) {
										layer.msg(message, {
											time: 2000,
											end: function() {
												// location.href = 'authorization.html'
											}
										})
									} else {
										layer.msg(message);
									}
								})
						}
					}
				}
			})
		</script>
	</body>
</html>
